package com.czumi.javawx.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import com.czumi.javawx.dao.entity.SysUser;
import com.czumi.javawx.dao.repository.SysUserRepository;

@Service
public class SysUserService {

	@Autowired
	private SysUserRepository sysUserRepository;

	public List<SysUser> getAllUser() {
		return sysUserRepository.findAll();
	}
	/**
	 * 条件检索
	 * 
	 * @param user
	 * @return
	 */
	public List<SysUser> getUsersByCondition(SysUser user) {
		Example<SysUser> example = Example.of(user);
		return sysUserRepository.findAll(example);
	}
	
	
	public SysUser getUserByCondition(SysUser user) {
		Example<SysUser> example = Example.of(user);
		return sysUserRepository.findOne(example);
	}

	public void saveAndUpdate(SysUser user) {
		sysUserRepository.saveAndFlush(user);
	}

	public void delete(SysUser user) {
		sysUserRepository.delete(user);
	}

}
